package demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Microsoft
 * Date: 2022-11-28
 * Time: 19:26
 */

interface  IShape {
    public String name = "1";
    public void draw();
    default public void func() {
        System.out.println("默认的");
    }
    public static void staticFunc() {
        System.out.println("123");
    }
}
class Rect implements IShape {
    @Override
    public void draw() {
        System.out.println("矩形");
    }

    @Override
    public void func() {
        System.out.println("重写这个方法");
    }
}
class Flower implements IShape {
    @Override
    public void draw() {
        System.out.println("❀");
    }
}
public class Test {
    public static void drawMap(IShape shape) {
        shape.draw();
    }
    public static void main(String[] args) {
        //IShape shape = new IShape() ;  //error
        IShape shape = new Rect();  //向上转型
        IShape shape2 = new Flower();  //向上转型
        drawMap(shape);
        drawMap(shape2);
        IShape.staticFunc();
    }
}














